************************************************
*Robustness to firm-level worldwide trade shock*
************************************************
* GENERATES TABLE REFERED TO IN footnote 17
*
use tempfirst, clear
eststo clear
global depvar_d1 = "theil_d1"
global nbnc8iso2 " "
global nbnc8iso2_d1 " "
drop shrexptimes*
*
merge m:1 firmid year using tradeshocks , keepusing(shrexptimes*)
drop if _merge == 2
drop _merge ltradeshock3w ltradeshock3iw
gen lgdpshock3w = (shrexptimesGDP1)
gen lgdpshock6w = (shrexptimesGDP2)
gen ltradeshock3w = (shrexptimesWLD1)
gen ltradeshock6w = (shrexptimesWLD2)
gen ltradeshock3iw = (shrexptimesWLDi1)
gen ltradeshock6iw = (shrexptimesWLDi2)
label var lgdpshock6w "$\tilde{\Delta}$ GDP Shock (world)"
label var ltradeshock6w "$\tilde{\Delta}$ trade shock (world)"
label var ltradeshock6iw "$\tilde{\Delta}$ trade shock - ISIC (world)"
*
eststo clear
*FE+FD Skewness
eststo: xtreg $depvar_d1 lgdpshock6  lgdpshock6w $nbnc8iso2_d1 yd* , robust cluster(firmiso) fe i(firmiso)
eststo: xtreg $depvar_d1 ltradeshock6 ltradeshock6w $nbnc8iso2_d1 yd* , robust cluster(firmiso) fe i(firmiso)
eststo: xtreg $depvar_d1 ltradeshock6i  ltradeshock6iw $nbnc8iso2_d1 yd* , robust cluster(firmiso) fe i(firmiso)
*
keep if nbnc8iso2>1
keep if nbnc8_max>1
keep if theil_d1 !=.
*same sample as later
gen lexport_int_d1 = lexport_d1 - lnbnc8iso2_d1
global depvar_d1 = "lexport_int_d1"
global nbnc8iso2_d1 "lnbnc8iso2_d1"
egen isiciso = group(isic iso2_d)
*
*FD Extensive/Intensive
global clustvar "iso2_d"
eststo: reg $depvar_d1 lgdpshock6 lgdpshock6w  yd* , robust cluster($clustvar)
global clustvar "firmiso"
eststo: reg $depvar_d1 ltradeshock6 ltradeshock6w yd* , robust cluster($clustvar)
global clustvar "isiciso"
eststo: reg $depvar_d1 ltradeshock6i ltradeshock6iw yd* , robust cluster($clustvar)
*
global clustvar "iso2_d"
eststo: reg $nbnc8iso2_d1 lgdpshock6 lgdpshock6w  yd* , robust cluster($clustvar)
global clustvar "firmiso"
eststo: reg $nbnc8iso2_d1 ltradeshock6 ltradeshock6w yd* , robust cluster($clustvar)
global clustvar "isiciso"
eststo: reg $nbnc8iso2_d1 ltradeshock6i ltradeshock6iw yd* , robust cluster($clustvar)
*
log using $DIRLOG/Replication/tab-1ststage_WWshockRobust.txt, text replace
set linesize 250
esttab, drop(yd* ) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, drop(yd* ) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close
*

